package com.xq.model.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xq.model.dto.PostDataTransferDTO;
import com.xq.model.entity.TBaseSurfMin;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 中国地面分钟要素 Mapper 接口
 *
 * @author xu
 * 2021/8/20 10:46
 */
public interface TBaseSurfMinMapper extends BaseMapper<TBaseSurfMin> {
    /**
     * 获取最大访问轮次
     * @return
     */
    @Select(value = "SELECT max(request_num) FROM t_base_surf_min")
    Integer selectMaxRequestNum();

    /**
     * 根据数据类型统计要素数量
     * @return
     */
    @Select(value = "SELECT Station_Id_C as stationIdC,\n" +
            "\tsum(case when surf_id then 1 else 0 end) as shouldNum,\n" +
            "\tsum(case when surf_type ='1' then 1 else 0 end) as inNum,\n" +
            "\tsum(case when surf_type ='2' then 1 else 0 end) as missNum,\n" +
            "\tsum(case when surf_type ='3' then 1 else 0 end) as overNum\n" +
            "FROM t_base_surf_min\n" +
            "GROUP BY Station_Id_C\t")
    List<PostDataTransferDTO> countDataTransfer();
}
